package com.wangjw.aop;

import org.springframework.aop.framework.ProxyFactory;

/**
 * Created by wangjw on 18/6/19.
 */
public class Client {

    public static void main(String[] args) {
        ProxyFactory proxyFactory = new ProxyFactory(); // 创建代理工厂
        proxyFactory.setTarget(new GreetingImpl()); // 射入目标类对象
//        proxyFactory.addAdvice(new GreetingBeforeAdvice()); // 添加前置增强
//        proxyFactory.addAdvice(new GreetingAfterAdvice()); // 添加后置增强
//        proxyFactory.addAdvice(new GreetingBeforeAndAfterAdvice());

        proxyFactory.addAdvice(new GreetingAroundAdvice()); // 添加环绕增强

        Greeting greeting = (Greeting) proxyFactory.getProxy(); // 从代理工厂中获取代理
        greeting.say("Jack"); // 调用代理的方法
    }
}
